
foreach var in alwaysin2memberhh {
eststo a: quietly estpost summarize ///
age female spouse ///
if `var' == 0 & edate_id==1335, detail

eststo b: quietly estpost summarize ///
age female spouse ///
if `var' == 1 & edate_id==1335, detail

eststo diff: quietly estpost ttest ///
age female spouse ///
if `var'==1 & edate_id==1335 ///
| `var'==0 & edate_id==1335 ///
, by(`var')

esttab a b diff using "Tables/Diffind2memb1membDem.tex", replace ///
cells("mean(label(Mean) pattern(1 1 0) fmt(%15.1fc)) sd(label(Standard dev.) par pattern(1 1 0) fmt(%15.1fc)) p50(label(Median) pattern(1 1 0) fmt(%15.1fc)) b(label(Diff.) star pattern(0 0 1) fmt(%15.1fc)) se(label(Std. error) par pattern(0 0 1) fmt(%15.1fc)) count(label(\#obs) pattern(0 0 1) fmt(%15.0fc))") ///
mtitle("Never linked" "Always linked" "") ///
noobs booktabs ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
rename(age "?quad Age" female "?quad Female" spouse "?quad Spouse") ///
substitute(? \) 
}

foreach var in alwaysin2memberhh {
eststo a: quietly estpost summarize ///
w1_total_income w1_reg_income w1_irr_income w1_salary ///
total_fin_cost sa_bal ca_bal ccard_bal ///
utvextir od_amount ///
cash liquidity  ///
cons1 cons2 od_exp ///
drattarv fit kostn2 ///
w1_total_exp w1_nec w1_unnec ///
if `var' == 0, detail

eststo b: quietly estpost summarize ///
w1_total_income w1_reg_income w1_irr_income w1_salary ///
total_fin_cost sa_bal ca_bal ccard_bal ///
utvextir od_amount ///
cash liquidity  ///
cons1 cons2 od_exp ///
drattarv fit kostn2 ///
w1_total_exp w1_nec w1_unnec ///
if `var' == 1, detail

eststo diff: estpost ttest ///
w1_total_income w1_reg_income w1_irr_income w1_salary ///
total_fin_cost sa_bal ca_bal ccard_bal ///
utvextir od_amount ///
cash liquidity  ///
cons1 cons2 od_exp ///
drattarv fit kostn2 ///
w1_total_exp w1_nec w1_unnec ///
if `var'==1 ///
| `var'==0 ///
, by(`var')

esttab a b diff using "Tables/Diffind2memb1memb2.tex", replace ///
cells("mean(label(Mean) pattern(1 1 0) fmt(%15.0fc)) sd(label(Standard dev.) par pattern(1 1 0) fmt(%15.0fc)) p50(label(Median) pattern(1 1 0) fmt(%15.0fc)) b(label(Diff.) star pattern(0 0 1) fmt(%15.0fc)) se(label(Std. error) par pattern(0 0 1) fmt(%15.0fc)) count(label(\#obs) pattern(0 0 1) fmt(%15.0fc))") ///
mtitle("Never linked" "Always linked" "") ///
noobs booktabs ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
rename(w1_total_income "?quad Total income$^1$" w1_reg_income "?quad Regular income$^1$" w1_irr_income "?quad Irregular income$^1$" ///
w1_salary "?quad Salary$^1$" total_fin_cost "?quad Total financial cost" ///
sa_bal "?quad Savings account balance" ca_bal "?quad Current account balance" ///
ccard_bal "?quad Credit card balance" ///
utvextir "?quad Overdraft interest" ///
od_amount "?quad Overdraft" cash "?quad Cash" ///
liquidity "?quad Liquidity" ///
cons1 "?quad Cash (cons. days)" cons2 "?quad Liquidity (cons. days)" ///
od_exp "?quad Overdraft (cons. days)" ///
drattarv "?quad Late-payment interest" ///
fit "?quad Non-sufficient funds fees" kostn2 "?quad Late fees" ///
w1_total_exp "?quad Total expenditures$^1$" w1_nec "?quad Necessities$^1$" ///
w1_unnec "?quad Non-necessities$^1$") ///
substitute(? \) 
}

*Only positive balances:
foreach var in alwaysin2memberhh {
eststo a: quietly estpost summarize ///
p_w1_total_income p_w1_reg_income p_w1_irr_income p_w1_salary ///
p_total_fin_cost p_sa_bal p_ca_bal p_ccard_bal ///
p_utvextir p_od_amount ///
p_cash p_liquidity  ///
p_cons1 p_cons2 p_od_exp ///
p_drattarv p_fit p_kostn2 ///
p_w1_total_exp p_w1_nec p_w1_unnec ///
if `var' == 0, detail

eststo b: quietly estpost summarize ///
p_w1_total_income p_w1_reg_income p_w1_irr_income p_w1_salary ///
p_total_fin_cost p_sa_bal p_ca_bal p_ccard_bal ///
p_utvextir p_od_amount ///
p_cash p_liquidity  ///
p_cons1 p_cons2 p_od_exp ///
p_drattarv p_fit p_kostn2 ///
p_w1_total_exp p_w1_nec p_w1_unnec ///
if `var' == 1, detail

eststo diff: estpost ttest ///
p_w1_total_income p_w1_reg_income p_w1_irr_income p_w1_salary ///
p_total_fin_cost p_sa_bal p_ca_bal p_ccard_bal ///
p_utvextir p_od_amount ///
p_cash p_liquidity  ///
p_cons1 p_cons2 p_od_exp ///
p_drattarv p_fit p_kostn2 ///
p_w1_total_exp p_w1_nec p_w1_unnec ///
if `var'==1 ///
| `var'==0 ///
, by(`var')

esttab a b diff using "Tables/Diffind2memb1memb2pos.tex", replace ///
cells("mean(label(Mean) pattern(1 1 0) fmt(%15.0fc)) sd(label(Standard dev.) par pattern(1 1 0) fmt(%15.0fc)) p50(label(Median) pattern(1 1 0) fmt(%15.0fc)) b(label(Diff.) star pattern(0 0 1) fmt(%15.0fc)) se(label(Std. error) par pattern(0 0 1) fmt(%15.0fc)) count(label(\#obs) pattern(0 0 1) fmt(%15.0fc))") ///
mtitle("Always linked" "Never linked" "") ///
noobs booktabs ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
rename(p_w1_total_income "?quad Total income$^1$" p_w1_reg_income "?quad Regular income$^1$" p_w1_irr_income "?quad Irregular income$^1$" ///
p_w1_salary "?quad Salary$^1$" p_total_fin_cost "?quad Total financial cost" ///
p_sa_bal "?quad Savings account balance" p_ca_bal "?quad Current account balance" ///
p_ccard_bal "?quad Credit card balance" ///
p_utvextir "?quad Overdraft interest" ///
p_od_amount "?quad Overdraft" p_cash "?quad Cash" ///
p_liquidity "?quad Liquidity" ///
p_cons1 "?quad Cash (cons. days)" p_cons2 "?quad Liquidity (cons. days)" ///
p_od_exp "?quad Overdraft (cons. days)" ///
p_drattarv "?quad Late-payment interest" ///
p_fit "?quad Non-sufficient funds fees" p_kostn2 "?quad Late fees" ///
p_w1_total_exp "?quad Total expenditures$^1$" p_w1_nec "?quad Necessities$^1$" ///
p_w1_unnec "?quad Non-necessities$^1$") ///
substitute(? \) 
}

*How linked households who cohold differ from households who don't cohold
*(difference in nominal terms)
sort hh_edate
foreach var in ///
w1_total_income w1_reg_income w1_irr_income w1_salary ///
total_fin_cost sa_bal ca_bal ccard_bal ///
utvextir od_amount ///
cash liquidity  ///
cons1 cons2 od_exp ///
drattarv fit kostn2 ///
w1_total_exp w1_nec w1_unnec {
gen diff_`var' = abs(`var'[_n]-`var'[_n+1]) if hh_edate[_n]==hh_edate[_n+1]
replace diff_`var' = diff_`var'[_n-1] if diff_`var'[_n-1]!=0 & diff_`var'[_n-1]!=. & hh_edate[_n]==hh_edate[_n-1]
replace diff_`var' = diff_`var'[_n+1] if diff_`var'[_n+1]!=0 & diff_`var'[_n+1]!=. & hh_edate[_n]==hh_edate[_n+1]
replace diff_`var' = 0 if diff_`var'[_n-1]==0 & hh_edate[_n]==hh_edate[_n-1]
replace diff_`var' = 0 if diff_`var'[_n+1]==0 & hh_edate[_n]==hh_edate[_n+1]
}

foreach var in coholder_HH {
eststo a: quietly estpost summarize ///
diff_w1_total_income diff_w1_reg_income ///
diff_w1_irr_income diff_w1_salary ///
diff_total_fin_cost diff_sa_bal diff_ca_bal diff_ccard_bal ///
diff_utvextir diff_od_amount ///
diff_cash diff_liquidity  ///
diff_cons1 diff_cons2 diff_od_exp ///
diff_drattarv diff_fit diff_kostn2 ///
diff_w1_total_exp diff_w1_nec diff_w1_unnec ///
if `var' == 0 & hh_edate_obs ==1

eststo b: quietly estpost summarize ///
diff_w1_total_income diff_w1_reg_income ///
diff_w1_irr_income diff_w1_salary ///
diff_total_fin_cost diff_sa_bal diff_ca_bal diff_ccard_bal ///
diff_utvextir diff_od_amount ///
diff_cash diff_liquidity  ///
diff_cons1 diff_cons2 diff_od_exp ///
diff_drattarv diff_fit diff_kostn2 ///
diff_w1_total_exp diff_w1_nec diff_w1_unnec ///
if `var' == 1 & hh_edate_obs ==1

eststo diff: estpost ttest ///
diff_w1_total_income diff_w1_reg_income ///
diff_w1_irr_income diff_w1_salary ///
diff_total_fin_cost diff_sa_bal diff_ca_bal diff_ccard_bal ///
diff_utvextir diff_od_amount ///
diff_cash diff_liquidity  ///
diff_cons1 diff_cons2 diff_od_exp ///
diff_drattarv diff_fit diff_kostn2 ///
diff_w1_total_exp diff_w1_nec diff_w1_unnec ///
if `var'==1 & hh_edate_obs ==1 ///
| `var'==0 & hh_edate_obs ==1 ///
, by(`var')
}

esttab a b diff using "Tables/HHCoholders_VS_HHNon.tex", replace ///
cells("mean(label(Mean) pattern(1 1 0) fmt(%15.0fc)) sd(label(Standard dev.) par pattern(1 1 0) fmt(%15.0fc)) b(label(Diff.) star pattern(0 0 1) fmt(%15.0fc)) se(label(Std. error) par pattern(0 0 1) fmt(%15.0fc)) count(label(\#obs) pattern(0 0 1) fmt(%15.0fc))") ///
mtitle("Non-coholder household" "Coholder household" "") ///
noobs booktabs ///
starlevels(* 0.10 ** 0.05 *** 0.01) ///
rename( ///
diff_w1_total_income "?quad Total income$^1$" ///
diff_w1_reg_income "?quad Regular income$^1$" ///
diff_w1_irr_income "?quad Irregular income$^1$" ///
diff_w1_salary "?quad Salary$^1$" ///
diff_total_fin_cost "?quad Total financial cost" ///
diff_sa_bal "?quad Savings account balance" ///
diff_ca_bal "?quad Current account balance" ///
diff_ccard_bal "?quad Credit card balance" ///
diff_utvextir "?quad Overdraft interest" ///
diff_od_amount "?quad Overdraft" ///
diff_cash "?quad Cash" ///
diff_liquidity "?quad Liquidity" ///
diff_cons1 "?quad Cash (cons. days)" ///
diff_cons2 "?quad Liquidity (cons. days)" ///
diff_od_exp "?quad Overdraft (cons. days)" ///
diff_drattarv "?quad Late-payment interest" ///
diff_fit "?quad Non-sufficient funds fees" ///
diff_kostn2 "?quad Late fees" ///
diff_w1_total_exp "?quad Total expenditures$^1$" ///
diff_w1_nec "?quad Necessities$^1$" ///
diff_w1_unnec "?quad Non-necessities$^1$") ///
substitute(? \) 





















